import time

def sort_file(nums):
    swapped = True
    while swapped:
        swapped = False
        for i in range(len(nums) - 1):
            if nums[i] > nums[i + 1]:
                nums[i], nums[i + 1] = nums[i + 1], nums[i]
                swapped = True


def file_open(filename):
    file = open(filename, 'r')
    data = file.readlines()
    return data


m1 = file_open('m1_sorted.txt')
start = time.time()
m1 = sort_file(m1)
stop = time.time()
print('m1_sorted.txt', round((stop - start) * 1000), 'milliseconds')

m2 = file_open("m2_reverse.txt")
start = time.time()
m2 = sort_file(m2)
stop = time.time()
print('m2_reverse.txt', round((stop - start) * 1000), 'milliseconds')

m3 = file_open("m3_shuffle.txt")
start = time.time()
m3 = sort_file(m3)
stop = time.time()
print('m3_shuffle.txt', round((stop - start) * 1000), 'milliseconds')
